package iface;

import java.io.Serializable;

/**
 * Object used to update user's location
 * 
 * @author Jeff
 * 
 */
public class Location implements Serializable, Message {
    private static final long serialVersionUID = 2L;
    private double lng;
    private double lat;
    private String username;

    /**
     * Constructs a new Location object
     * 
     * @param username
     *            the user's name
     * @param lng
     *            the user's longitude
     * @param lat
     *            the user's latitude
     */
    public Location(String username, double lng, double lat) {
        this.lng = lng;
        this.lat = lat;
        this.username = username;
    }

    /**
     * Constructs a new Location object
     * 
     * @param lng
     *            the user's longitude
     * @param lat
     *            the user's latitude
     */
    public Location(double lng, double lat) {
        this(null, lng, lat);
    }

    /**
     * @return the latitude
     */
    public double getLat() {
        return lat;
    }

    /**
     * @return the longitude
     */
    public double getLong() {
        return lng;
    }

    /**
     * @return the user's name
     */
    public String getUsername() {
        return this.username;
    }

    /**
     * @return a String representation of a latitude object
     */
    public String toString() {
        return this.username + ", lat: " + this.lat + ", long: " + this.lng;
    }

    /**
     * @param other
     *            the other Location to compare with
     * @return true if they are equal, false otherwise
     */
    public boolean locEquals(Location other) {
        return (this.lat == other.lat) && (this.lng == other.lng);
    }

}
